home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 13
/
Aminet 13 - August 1996.iso
/
Aminet
/
dev
/
e
/
bits.lha
/
bits
/
bits.doc
next >
Wrap
Text File
|
1996-06-08
|
3KB
|
84 lines
bits.m is a little module which supports some procedures which
manipulates values on the bit level.
bits.m v1.0 (07-Jun-96) is copyright by:
Ralph Wermke of Digital Innovations
Prokofjewstr. 7B
17491 Greifswald
Germany
EMail: wermke@gryps1.rz.uni-greifswald.de
WWW : http://www.fh-stralsund.de/~rwermke/di.html
!! THIS MODULE IS FREEWARE !!
If you are interested at the source please write me a note.
+++++++++++++++++
+++ Functions +++
+++++++++++++++++
bitset (value, bit)
Sets the bit 'bit' in 'value'. The valid range for 'bit' is 0-31.
bitclear (value, bit)
Clears the bit 'bit' in 'value'. The valid range for 'bit' is 0-31.
bittest (value, bit)
Tests the bit 'bit' in 'value' and returns the current state.
The valid range for 'bit' is 0-31.
bitchange (value, bit)
Changes the bit 'bit' in 'value' in the following way 0->1 and 1->0.
The valid range for 'bit' is 0-31.
bitdset (value, bit, dep)
Sets 'dep' to bit 'bit' in 'value'.
That means that the bit will be set directly to the value in 'dep'.
The valid range for 'bit' is 0-31.
'dep' must be 0 or 1.
swap (value, what)
This function swaps bytes/words in several ways.
'what' stays for the kind of swapping.
The following are supported yet:
SWAP_LONG - swaps both word of a long
$11223344 -> $33441122
SWAP_HIGH - swaps the bytes of the high word of a long
$11223344 -> $22113344
SWAP_LOW - swaps the bytes of the low word of a long
$11223344 -> $11224433
SWAP_INNER - swaps the both inner bytes of a long
$11223344 -> $11332244
SWAP_OUTER - swaps the both outer bytes of a long
$11223344 -> $44223311
bintostr (value, size, str)
Converts the value 'value' to a string 'str ' containing a binary
number. 'Size' is number of bits to convert.
For this some values are predefined:
SIZE_LONG = 32
SIZE_WORD = 16
SIZE_BYTE = 8
But you can also use all values beteen 1 and 32.
The lenght of the string MUST be at least size+1, if not your
machine can crash.
strtobin (str, size)
With this function you can reconvert a string 'str' which is
containing a binary number to a normal number (long).
The function converts 'size' numbers of bits or if the stringlenght
is shorter till the end of the string.
For 'size' use the same values as before.
*** Write me, if you found bugs, have any suggestions or you miss ***
*** a function you need. ***